package com.meisupic.copyright.repo;

import com.meisupic.copyright.domain.po.Users;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * creation wuxun
 * @version V1.0
 * @Description: user数据库访问
 * @date 2018/1/13 15:54
 */
public interface UsersRepo extends JpaRepository<Users, Long> {

  @Modifying
  @Transactional
  @Query("update Users u set u.password=:password where u.id= :id")
  int updatePassword(@Param("password") String password, @Param("id") Long id);

  List<Users> findByUserNameIs(String userName);

  Users findUsersByHuabanUserIdIs(Long huabanUserId);

  Users findUsersByUserNameIs(String userName);


  @Modifying
  @Transactional
  @Query("update Users u set u.mobile=:mobile where u.id= :id")
  int updateMobile(@Param("mobile") String mobile, @Param("id") Long id);


}